#pragma once

#include <gofcl_rcu_r.h>

typedef struct {
	u8_s SCS : 2;
	u8_s SCSS : 2;
	u8_s AHBPSC : 4;
} rcu_cfg0_0_7_s;

_Static_assert(sizeof(rcu_cfg0_0_7_s) == 1,
	       "Struct rcu_cfg0_0_7_s defined error!");

static inline void rcu_wreg_cfg0_0_7_s(rcu_cfg0_0_7_s cfg0_0_7) {
	union {
		rcu_cfg0_0_7_s c;
		u8_s u;
	} cu = {
		.c = cfg0_0_7,
	};
	rcu_wreg_u8(RCU_CFG0_R, T8B_0_R, cu.u);
}

static inline rcu_cfg0_0_7_s rcu_rreg_cfg0_0_7_s(void) {
	union {
		rcu_cfg0_0_7_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u8(RCU_CFG0_R, T8B_0_R),
	};
	return cu.c;
}

typedef struct {
	u8_s APB1PSC : 3;
	u8_s APB2PSC : 3;
	u8_s ADCPSC_0_1 : 2;
} rcu_cfg0_8_15_s;

_Static_assert(sizeof(rcu_cfg0_8_15_s) == 1,
	       "Struct rcu_cfg0_8_15_s defined error!");

static inline void rcu_wreg_cfg0_8_15_s(rcu_cfg0_8_15_s cfg0_8_15) {
	union {
		rcu_cfg0_8_15_s c;
		u8_s u;
	} cu = {
		.c = cfg0_8_15,
	};
	rcu_wreg_u8(RCU_CFG0_R, T8B_1_R, cu.u);
}

static inline rcu_cfg0_8_15_s rcu_rreg_cfg0_8_15_s(void) {
	union {
		rcu_cfg0_8_15_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u8(RCU_CFG0_R, T8B_1_R),
	};
	return cu.c;
}

typedef struct {
	rcu_cfg0_0_7_s cfg0_0_7;
	rcu_cfg0_8_15_s cfg0_8_15;
} __attribute__((aligned(2))) rcu_cfg0_0_15_s;

_Static_assert(sizeof(rcu_cfg0_0_15_s) == 2,
	       "Struct rcu_cfg0_0_15_s defined error!");

static inline void rcu_wreg_cfg0_0_15_s(rcu_cfg0_0_15_s cfg0_0_15) {
	union {
		rcu_cfg0_0_15_s c;
		u16_s u;
	} cu = {
		.c = cfg0_0_15,
	};
	rcu_wreg_u16(RCU_CFG0_R, T16B_0_R, cu.u);
}

static inline rcu_cfg0_0_15_s rcu_rreg_cfg0_0_15_s(void) {
	union {
		rcu_cfg0_0_15_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u16(RCU_CFG0_R, T16B_0_R),
	};
	return cu.c;
}

typedef struct {
	u8_s PLLSEL : 1;
	u8_s PREDV0_LSB : 1;
	u8_s PLLMF_0_3 : 4;
	u8_s USBFSPSC : 2;
} rcu_cfg0_16_23_s;

_Static_assert(sizeof(rcu_cfg0_16_23_s) == 1,
	       "Struct rcu_cfg0_16_23_s defined error!");

static inline void rcu_wreg_cfg0_16_23_s(rcu_cfg0_16_23_s cfg0_16_23) {
	union {
		rcu_cfg0_16_23_s c;
		u8_s u;
	} cu = {
		.c = cfg0_16_23,
	};
	rcu_wreg_u8(RCU_CFG0_R, T8B_2_R, cu.u);
}

static inline rcu_cfg0_16_23_s rcu_rreg_cfg0_16_23_s(void) {
	union {
		rcu_cfg0_16_23_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u8(RCU_CFG0_R, T8B_2_R),
	};
	return cu.c;
}

typedef struct {
	u8_s CKOUT0SEL : 4;
	u8_s ADCPSC_2 : 1;
	u8_s PLLMF_4 : 1;
	u8_s : 2;
} rcu_cfg0_24_31_s;

_Static_assert(sizeof(rcu_cfg0_24_31_s) == 1,
	       "Struct rcu_cfg0_24_31_s defined error!");

static inline void rcu_wreg_cfg0_24_31_s(rcu_cfg0_24_31_s cfg0_24_31) {
	union {
		rcu_cfg0_24_31_s c;
		u8_s u;
	} cu = {
		.c = cfg0_24_31,
	};
	rcu_wreg_u8(RCU_CFG0_R, T8B_3_R, cu.u);
}

static inline rcu_cfg0_24_31_s rcu_rreg_cfg0_24_31_s(void) {
	union {
		rcu_cfg0_24_31_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u8(RCU_CFG0_R, T8B_3_R),
	};
	return cu.c;
}

typedef struct {
	rcu_cfg0_16_23_s cfg0_16_23;
	rcu_cfg0_24_31_s cfg0_24_31;
} __attribute__((aligned(2))) rcu_cfg0_16_31_s;

_Static_assert(sizeof(rcu_cfg0_16_31_s) == 2,
	       "Struct rcu_cfg0_16_31_s defined error!");

static inline void rcu_wreg_cfg0_16_31_s(rcu_cfg0_16_31_s cfg0_16_31) {
	union {
		rcu_cfg0_16_31_s c;
		u16_s u;
	} cu = {
		.c = cfg0_16_31,
	};
	rcu_wreg_u16(RCU_CFG0_R, T16B_2_R, cu.u);
}

static inline rcu_cfg0_16_31_s rcu_rreg_cfg0_16_31_s(void) {
	union {
		rcu_cfg0_16_31_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg_u16(RCU_CFG0_R, T16B_2_R),
	};
	return cu.c;
}

typedef struct {
	rcu_cfg0_0_7_s cfg0_0_7;
	rcu_cfg0_8_15_s cfg0_8_15;
	rcu_cfg0_16_23_s cfg0_16_23;
	rcu_cfg0_24_31_s cfg0_24_31;
} __attribute__((aligned(4))) rcu_cfg0_s;

_Static_assert(sizeof(rcu_cfg0_s) == 4, "Struct rcu_cfg0_s defined error!");

static inline void rcu_wreg_cfg0_s(rcu_cfg0_s cfg0) {
	union {
		rcu_cfg0_s c;
		u32_s u;
	} cu = {
		.c = cfg0,
	};
	rcu_wreg(RCU_CFG0_R, cu.u);
}

static inline rcu_cfg0_s rcu_rreg_cfg0_s(void) {
	union {
		rcu_cfg0_s c;
		u8_s u;
	} cu = {
		.u = rcu_rreg(RCU_CFG0_R),
	};
	return cu.c;
}
